package org.example.hansp.reflection.obtainc_class_structure_information;

import org.junit.jupiter.api.Test;

import java.lang.reflect.Method;

public class MethodAPI {
    Class< Person> personClazz=Person.class;
    @Test
    public void test1() {
        Method[] methods = personClazz.getDeclaredMethods();
        for (Method method : methods) {
            System.out.println("方法类型："+method.getModifiers());
            System.out.println("方法名： "+method.getName());
            System.out.println("方法返回类型： "+method.getReturnType());
            Class<?>[] parameterTypes = method.getParameterTypes();//获取该方法的所有参数
            for (Class<?> parameterType : parameterTypes) {
                System.out.print("\t该方法的形参类型："+parameterType);
            }
        }

    }
}
